import http from '../common/http.js'
// 上传图片
export const uploadImg = data => {
	return new Promise((resolve, reject) => {
		let imgList = []
		try {
			data.tempFilePaths.forEach((item, i) => {
				uni.uploadFile({
					url: http.BASE_URL + '/api/common/upload',
					formData: {
						'token': uni.getStorageSync('token'),
					},
					name: 'file',
					// #ifdef MP
					filePath: data.tempFilePaths[i],
					// #endif
					// #ifdef H5
					files: [{
						name: 'file',
						file: data.tempFiles[i],
						uri: data.tempFilePaths[i],
					}],
					// #endif
					success: res => {
						console.log(res)
						if (res.statusCode == 200) {
							let info = JSON.parse(res.data)
							if (info.code == 1) {
								imgList.push(info.data.url)
							}
							console.log(imgList)
							if (data.tempFiles.length == imgList.length) {
								resolve(imgList)
							}
						} else {
							imgList.push(data.tempFilePaths[i])
							resolve(imgList)
						}
					},
					fail(err) {
						console.log(err)
					},
					template() {
						console.log('1231311312')
					}
				});
			})
		} catch (e) {
			uni.hideLoading()
			uni.showToast({
				title: '服务器或网络异常，请稍候重试',
				icon: 'none'
			})
		}
	})
}
// 首页接口
export const index = (data) => {
	return http.post({
		url: 'api/index/index',
		data: {
			...data
		}
	})
}
// 今日指导价
export const guidanceList = (data) => {
	return http.post({
		url: 'api/index/guidanceList',
		data: {
			...data
		}
	})
}
// 今日指导价详情
export const guidancePrice = (data) => {
	return http.post({
		url: 'api/index/guidancePrice',
		data: {
			...data
		}
	})
}
// 回收站列表
export const recycle = (data) => {
	return http.post({
		url: 'api/index/recycle',
		data: {
			...data
		}
	})
}

// 爱心积攒
export const mission = (data) => {
	return http.post({
		url: 'api/index/mission',
		data: {
			...data
		}
	})
}

// 商品分类
export const shopSort = () => {
	return http.post({
		url: 'api/index/shopSort',
	})
}

// 立即下单
export const placeOrder = (data) => {
	return http.post({
		url: 'api/index/order',
		data: {
			...data
		}
	})
}

// 地址簿
export const userAddress = (data) => {
	return http.post({
		url: 'api/index/userAddress',
		data: {
			...data
		}
	})
}

// 预估重量
export const weight = (data) => {
	return http.post({
		url: 'api/index/weight',
		data: {
			...data
		}
	})
}

// 添加地址
export const addAddress = (data) => {
	return http.post({
		url: 'api/index/addAddress',
		data: {
			...data
		}
	})
}

// 删除地址
export const delAddress = (data) => {
	return http.post({
		url: 'api/index/delAddress',
		data: {
			...data
		}
	})
}

// 设置默认地址
export const setAddress = (data) => {
	return http.post({
		url: 'api/index/setAddress',
		data: {
			...data
		}
	})
}

// 取消订单
export const delOrder = (data) => {
	return http.post({
		url: 'api/index/delOrder',
		data: {
			...data
		}
	})
}

// 编辑地址
export const siteAddres = (data) => {
	return http.post({
		url: 'api/index/siteAddres',
		data: {
			...data
		}
	})
}

// 回收员入驻
export const recyclerApply = (data) => {
	return http.post({
		url: 'api/settled/index',
		data: {
			...data
		}
	})
}

// 回收员入驻
export const recycleBinApply = (data) => {
	return http.post({
		url: 'api/settled/recycle',
		data: {
			...data
		}
	})
}

// 系统消息
export const message = (data) => {
	return http.post({
		url: 'api/settled/message',
		data: {
			...data
		}
	})
}

// 接单大厅
export const orderList = (data) => {
	return http.post({
		url: 'api/settled/orderList',
		data: {
			...data
		}
	})
}

// 确认接单
export const saveOrder = (data) => {
	return http.post({
		url: 'api/settled/saveOrder',
		data: {
			...data
		}
	})
}

// 用户信息
export const getUserInfo = (data) => {
	return http.post({
		url: 'api/member/getUser',
		data: {
			...data
		}
	})
}

// 个人中心修改
export const editInfo = (data) => {
	return http.post({
		url: 'api/user/editInfo',
		data: {
			...data
		}
	})
}

// openid
export const getOpenid = (data) => {
	return http.post({
		url: 'api/index/getCode',
		data: {
			...data
		}
	})
}

// 存储用户信息
export const setUserInfo = (data) => {
	return http.post({
		url: 'api/index/setUser',
		data: {
			...data
		}
	})
}

// 会员卡
export const getVip = (data) => {
	return http.post({
		url: 'api/user/pay',
		data: {
			...data
		}
	})
}

// 够买
export const payVip = (data) => {
	return http.post({
		url: 'api/pay/pay',
		data: {
			...data
		}
	})
}

// 获取默认地址
export const getDefaultAddress = (data) => {
	return http.post({
		url: 'api/index/getSaddress',
		data: {
			...data
		}
	})
}

// 订单列表
export const userOrder = (data) => {
	return http.post({
		url: 'api/order/index',
		data: {
			...data
		}
	})
}
// 订单列表
export const shopOrder = (data) => {
	return http.post({
		url: 'api/order/shop',
		data: {
			...data
		}
	})
}
// 订单详情
export const userOrderDetail = (data) => {
	return http.post({
		url: 'api/order/orderDesc',
		data: {
			...data
		}
	})
}
// 订单详情
export const shopOrderDetail = (data) => {
	return http.post({
		url: 'api/order/shopOrderDesc',
		data: {
			...data
		}
	})
}


// 回收员订单
export const recyleOrder = (data) => {
	return http.post({
		url: 'api/order/recyleOrder',
		data: {
			...data
		}
	})
}

// 订单投诉
export const complaint = (data) => {
	return http.post({
		url: 'api/order/complaint',
		data: {
			...data
		}
	})
}

// 订单评价
export const evaluate = (data) => {
	return http.post({
		url: 'api/order/evaluate',
		data: {
			...data
		}
	})
}

// 反馈信息
export const feedback = (data) => {
	return http.post({
		url: 'api/user/feedback',
		data: {
			...data
		}
	})
}

// 账户统计
export const statistics = (data) => {
	return http.post({
		url: 'api/user/statistics',
		data: {
			...data
		}
	})
}

// 消息通知读取状态
export const noticeStatus = (data) => {
	return http.post({
		url: 'api/user/show',
		data: {
			...data
		}
	})
}

// 回收站列表
export const recyle = (data) => {
	return http.post({
		url: 'api/Recyle/index',
		data: {
			...data
		}
	})
}


// 垃圾分类
export const sortList = (data) => {
	return http.post({
		url: 'api/recyle/sortList',
		data: {
			...data
		}
	})
}

// 公益详情
export const missionDesc = (data) => {
	return http.post({
		url: 'api/mechanism/activityDetail',
		data: {
			...data
		}
	})
}

// 获取地址信息
export const getAddress = (data) => {
	return http.post({
		url: 'api/index/editAddress',
		data: {
			...data
		}
	})
}

// 计算提交
export const orderAdd = (data) => {
	return http.post({
		url: 'api/order/orderAdd',
		data: {
			...data
		}
	})
}

// 确认订单
export const orderk = (data) => {
	return http.post({
		url: 'api/order/orderk',
		data: {
			...data
		}
	})
}

// 协议
export const regaggrement = (data) => {
	return http.post({
		url: 'api/settled/regaggrement',
		data: {
			...data
		}
	})
}
// 协议
export const orderov = (data) => {
	return http.post({
		url: 'api/order/orderov',
		data: {
			...data
		}
	})
}

export const mechanism = (data) => {
	return http.post({
		url: 'api/mechanism/lists',
		data: {
			...data
		}
	})
}

export const mechanismDetail = (data) => {
	return http.get({
		url: 'api/mechanism/detail',
		data: {
			...data
		}
	})
}
export const activity = (data) => {
	return http.get({
		url: 'api/mechanism/activity',
		data: {
			...data
		}
	})
}
export const newOrder = (data) => {
	return http.get({
		url: 'api/order/newOrder',
		data: {
			...data
		}
	})
}
export const angelApply = (data) => {
	return http.post({
		url: 'api/angel/apply',
		data: {
			...data
		}
	})
}
export const banner = (data) => {
	return http.get({
		url: 'api/usercenter/banner',
		data: {
			...data
		}
	})
}
export const hallOrderList = (data) => {
	return http.get({
		url: 'api/order/hallOrderList',
		data: {
			...data
		}
	})
}
export const promoteList = (data) => {
	return http.get({
		url: 'api/promote/lists',
		data: {
			...data
		}
	})
}

export const guideBanner = () => {
	return http.get({
		url: 'api/config/banner',
	})
}

export const getRecycle = (data) => {
	return http.post({
		url: 'api/index/recycle',
		data: {
			...data
		}
	})
}

export const getProtocol = () => {
	return http.post({
		url: 'api/config/protocol'
	})
}

export const getLove = (data) => {
	return http.post({
		url: 'api/config/love',
		data
	})
}

export const completeInfo = (data) => {
	return http.post({
		url: 'api/apply/recycler',
		data
	})
}

export const getRecyclerInfo = (data) => {
	return http.post({
		url: 'api/apply/getRecyclerInfo',
		data
	})
}

export const phoneAuth = (data) => {
	return http.post({
		url: 'api/phone/auth',
		data
	})
}

export const saveAddress = (data) => {
	return http.post({
		url: 'api/user/saveAddress',
		data
	})
}

// 回收员取消订单
export const cancelOrder = (data) => {
	return http.post({
		url: 'api/order/cancel',
		data
	})
}

// 配置文件 是都展示身份证
export const configCard = (data) => {
	return http.get({
		url: 'api/config/card',
		data
	})
}